package com.yanqu.road.entity.activity.sonhai.data;

import com.yanqu.road.entity.DataObject;
import com.yanqu.road.entity.DataStatus;
import com.yanqu.road.entity.FieldTypeAnnotation;
import com.yanqu.road.entity.activity.sonhai.config.SonHaiConfig;
import com.yanqu.road.entity.activity.sonhai.config.SonHaiEventConfig;
import com.yanqu.road.entity.activity.sonhai.config.SonHaiMapConfig;
import com.yanqu.road.entity.activity.sonhai.enums.*;
import com.yanqu.road.entity.activity.sonhai.param.SonHaiPlotBuffResp;
import com.yanqu.road.utils.plot.PlotUtil;
import com.yanqu.road.utils.plot.Point;
import com.yanqu.road.utils.string.StringUtils;

import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicInteger;

@FieldTypeAnnotation(tableName = "t_c_activity_son_hai_region_data")
public class SonHaiRegionData extends DataObject {

    @FieldTypeAnnotation(desc = "活动ID", select = true, update = true)
    private int activityId;

    @FieldTypeAnnotation(desc = "分组ID", select = true, update = true)
    private int groupId;

    @FieldTypeAnnotation(desc = "区域唯一ID")
    private int id;

    @FieldTypeAnnotation(desc = "队伍ID")
    private int teamId;

    @FieldTypeAnnotation(desc = "区域ID")
    private int regionId;

    @FieldTypeAnnotation(desc = "地图ID")
    private int mapId;

    @FieldTypeAnnotation(desc = "寻踪进度")
    private int progress;

    @FieldTypeAnnotation(desc = "兽王")
    private SonHaiBeastBossData beastBoss;

    @FieldTypeAnnotation(desc = "发起重置的玩家ID")
    private long launchRestUserId = 0;

    @FieldTypeAnnotation(desc = "同意重置区域的玩家ID")
    private Set<Long> agreeRestUserIds = new HashSet<>();

    @FieldTypeAnnotation(desc = "自动重置时间")
    private long autoRestTime = 0;

    @FieldTypeAnnotation(desc = "是否删除")
    private int delFlag;

    @FieldTypeAnnotation(desc = "创建时间")
    private long createTime;

    //地块MAP,k:坐标x_y,v:地块信息
    private Map<String, SonHaiPlotData> plotDataMap = new ConcurrentHashMap<>();

    //地块MAP,k:地块类型,v:类型地块LIST
    private Map<Integer, List<SonHaiPlotData>> plotTypeDataMap = new ConcurrentHashMap<>();

    //地块MAP,k:地块ID,v:地块数量
    private Map<Integer, Integer> plotIdNumMap = new ConcurrentHashMap<>();

    public SonHaiRegionData() {}

    public SonHaiRegionData(int activityId, int groupId, int teamId, int regionId, int regionUniqueId, int mapId) {
        this.id = regionUniqueId;
        this.activityId = activityId;
        this.groupId = groupId;
        this.teamId = teamId;
        this.regionId = regionId;
        this.mapId = mapId;
        this.createTime = System.currentTimeMillis();
        setInsertOption();
    }

    public int getActivityId() {
        return activityId;
    }
    public void setActivityId(int activityId) {
        if (this.activityId != activityId) {
            this.activityId = activityId;
            setOp(DataStatus.Update);
        }
    }

    public int getGroupId() {
        return groupId;
    }

    public void setGroupId(int groupId) {
        if (this.groupId != groupId) {
            this.groupId = groupId;
            setOp(DataStatus.Update);
        }
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        if (this.id != id) {
            this.id = id;
            setOp(DataStatus.Update);
        }
    }

    public int getTeamId() {
        return teamId;
    }
    public void setTeamId(int teamId) {
        if (this.teamId != teamId) {
            this.teamId = teamId;
            setOp(DataStatus.Update);
        }
    }

    public int getProgress() {
        return progress;
    }

    public void setProgress(int progress) {
        if (this.progress != progress) {
            this.progress = progress;
            setOp(DataStatus.Update);
        }
    }

    public synchronized void addProgress(int progress) {
        this.setProgress(this.progress + progress);
    }

    public int getRegionId() {
        return regionId;
    }
    public void setRegionId(int regionId) {
        if (this.regionId != regionId) {
            this.regionId = regionId;
            setOp(DataStatus.Update);
        }
    }

    public int getMapId() {
        return mapId;
    }

    public void setMapId(int mapId) {
        if (this.mapId != mapId) {
            this.mapId = mapId;
            setOp(DataStatus.Update);
        }
    }

    public long getLaunchRestUserId() {
        return launchRestUserId;
    }

    public void setLaunchRestUserId(long launchRestUserId) {
        if (this.launchRestUserId != launchRestUserId) {
            this.launchRestUserId = launchRestUserId;
            setOp(DataStatus.Update);
        }
    }

    public Set<Long> getAgreeRestUserIds() {
        return agreeRestUserIds;
    }

    public void setAgreeRestUserIds(Set<Long> agreeRestUserIds) {
        if (null == agreeRestUserIds){
            return;
        }
        if (this.agreeRestUserIds == null || !this.agreeRestUserIds.equals(agreeRestUserIds)) {
            this.agreeRestUserIds = agreeRestUserIds;
            setOp(DataStatus.Update);
        }
    }

    public void addAgreeRestUserIds(long userId) {
        this.agreeRestUserIds.add(userId);
        setOp(DataStatus.Update);
    }

    public void removeAgreeRestUserIds(long userId) {
        this.agreeRestUserIds.remove(userId);
        setOp(DataStatus.Update);
    }

    public long getAutoRestTime() {
        return autoRestTime;
    }

    public void setAutoRestTime(long autoRestTime) {
        if (this.autoRestTime != autoRestTime) {
            this.autoRestTime = autoRestTime;
            setOp(DataStatus.Update);
        }
    }

    public long getCreateTime() {
        return createTime;
    }

    public void setCreateTime(long createTime) {
        if (this.createTime != createTime) {
            this.createTime = createTime;
            setOp(DataStatus.Update);
        }
    }

    public int getDelFlag() {
        return delFlag;
    }

    public void setDelFlag(int delFlag) {
        if (this.delFlag != delFlag) {
            this.delFlag = delFlag;
            setOp(DataStatus.Update);
        }
    }

    public SonHaiBeastBossData getBeastBoss() {
        return beastBoss;
    }

    public void setBeastBoss(SonHaiBeastBossData beastBoss) {
        this.beastBoss = beastBoss;
    }

    public Map<String, SonHaiPlotData> getPlotDataMap() {
        return plotDataMap;
    }

    public void setPlotDataMap(Map<String, SonHaiPlotData> plotDataMap) {
        this.plotDataMap = plotDataMap;
    }

    public Map<Integer, List<SonHaiPlotData>> getPlotTypeDataMap() {
        return plotTypeDataMap;
    }

    public List<SonHaiPlotData> getPlotDataListByType(int type) {
        return plotTypeDataMap.getOrDefault(type, new ArrayList<>());
    }

    public void setPlotTypeDataMap(Map<Integer, List<SonHaiPlotData>> plotTypeDataMap) {
        this.plotTypeDataMap = plotTypeDataMap;
    }

    public Map<Integer, Integer> getPlotIdNumMap() {
        return plotIdNumMap;
    }

    public int getPlotNumByEventId(int eventId) {
        return plotIdNumMap.getOrDefault(eventId, 0);
    }

    /**
     * 获取日志,根据战斗类型
     * @param userId
     * @return
     */
    public List<SonHaiPlotData> getBattleLogListByBattleType(long userId, SonHaiPlotBattleTypeEnum battleType, SonHaiConfig sonHaiConfig) {
        List<SonHaiPlotData> result = new ArrayList<>();
        //普通战斗类型LIST
        List<SonHaiPlotTypeEnum> battleTypeList = SonHaiPlotTypeEnum.getTypesByBattleType(battleType);
        for (SonHaiPlotTypeEnum typeEnum : battleTypeList) {
            List<SonHaiPlotData> plotDataList = this.getPlotDataListByType(typeEnum.getType());
            if (plotDataList != null && !plotDataList.isEmpty()) {
                for (SonHaiPlotData plotData : plotDataList) {
                    SonHaiEventConfig eventConfig = sonHaiConfig.getEventConfig(plotData.getPlotId());
                    if (eventConfig == null) {
                        continue;
                    }
                    //无奖励的
                    if (StringUtils.isNullOrEmpty(eventConfig.getReward())) {
                        continue;
                    }
                    //判断地块是否被封锁
                    boolean isLock = this.checkPlotLock(plotData.getX(), plotData.getY(), sonHaiConfig);
                    if (isLock) {
                        continue;
                    }
                    //未镇伏
                    if (plotData.getWinFlag() == SonHaiWinFlagEnum.WIN_NOT.getType()) {
                        result.add(plotData);
                        continue;
                    }
                    //自己的地块 && 已镇伏 && 奖励未领取的
                    if (plotData.getUserId() == userId &&
                            plotData.getWinFlag() == SonHaiWinFlagEnum.WIN_YES.getType() &&
                            plotData.getGetRewardFlag() == SonHaiRewardFlagEnum.GET_NOT.getType()) {
                        result.add(plotData);
                    }
                }
            }
        }
        return result;
    }

    /**
     * 获取【探险互助红点】
     * @param userId
     * @return
     */
    public boolean getUserHelpRedDot(long userId) {
        //普通战斗类型LIST
        List<SonHaiPlotTypeEnum> battleTypeList = SonHaiPlotTypeEnum.getTypesByBattleType(SonHaiPlotBattleTypeEnum.PLOT_BATTLE_TYPE_NORMAL);
        for (SonHaiPlotTypeEnum typeEnum : battleTypeList) {
            List<SonHaiPlotData> plotDataList = this.getPlotDataListByType(typeEnum.getType());
            if (plotDataList != null && !plotDataList.isEmpty()) {
                for (SonHaiPlotData plotData : plotDataList) {
                    //已镇伏的 && 奖励未领取的 && 自己的
                    if (plotData.getWinFlag() == SonHaiWinFlagEnum.WIN_YES.getType() && plotData.getGetRewardFlag() == SonHaiRewardFlagEnum.GET_NOT.getType() && plotData.getUserId() == userId) {
                        return true;
                    }
                }
            }
        }
        return false;
    }

    /**
     * 获取地块信息
     * @param x
     * @param y
     * @return
     */
    public SonHaiPlotData getPlotData(int x, int y) {
        return this.plotDataMap.get(x + "_" + y);
    }

    /**
     * 添加地块
     * @param plotData
     */
    public void addPlot(SonHaiPlotData plotData) {
        this.plotDataMap.put(plotData.getX() + "_" + plotData.getY(), plotData);
        //地块类型=>地块LIST
        List<SonHaiPlotData> plotDataList = this.plotTypeDataMap.computeIfAbsent(plotData.getType(), k -> new ArrayList<>());
        plotDataList.add(plotData);
        //地块ID=>数量MAP
        int num = this.plotIdNumMap.getOrDefault(plotData.getPlotId(),0);
        this.plotIdNumMap.put(plotData.getPlotId(), num + 1);
    }

    /**
     * 获取兽王地块
     * @return
     */
    public SonHaiPlotData getBeastKingPlot() {
        List<SonHaiPlotData> plotDataList = this.plotTypeDataMap.get(SonHaiPlotTypeEnum.PLOT_TYPE_1.getType());
        if (plotDataList != null && !plotDataList.isEmpty()) {
            return plotDataList.get(0);
        }
        return null;
    }

    /**
     * 创建地块
     * @param userId
     * @param x
     * @param y
     * @param activityId
     * @param groupId
     * @param eventConfig 事件配置
     * @return
     */
    public SonHaiPlotData createPlot(long userId, int x, int y, int activityId, int groupId, SonHaiEventConfig eventConfig) {
        //随机出地块
        int plotId = eventConfig.getId();
        int plotType = eventConfig.getEventType();
        int plotLevel = eventConfig.getLevel();
        SonHaiPlotData plotData = new SonHaiPlotData(
                activityId,
                groupId,
                this.getTeamId(),
                userId,
                this.getId(),
                this.getRegionId(),
                x,
                y,
                plotId,
                plotType,
                plotLevel
        );
        this.addPlot(plotData);
        return plotData;
    }

    /**
     * 检查探索的地块是否合法-不校验相邻地块是否被探索过
     * @param x
     * @param y
     * @return
     */
    public boolean checkPlotNotAdJoin(int x, int y, SonHaiConfig sonHaiConfig) {
        //1.判断地块是否已经被探索
        SonHaiPlotData plotData = this.getPlotDataMap().get(x + "_" + y);
        if (plotData != null) {
            return false;
        }
        //地块是否可探索，判断是否超出地图范围
        SonHaiMapConfig mapConfig = sonHaiConfig.getMapConfig(this.mapId);
        if (mapConfig == null) {
            return false;
        }
        return mapConfig.checkPosition(x, y);
    }

    /**
     * 检查探索的地块是否合法
     * @param x
     * @param y
     * @return
     */
    public boolean checkPlot(int x, int y, SonHaiConfig sonHaiConfig) {
        //1.判断地块是否已经被探索,2.判断是否超出地图范围，
        boolean flag = this.checkPlotNotAdJoin(x, y, sonHaiConfig);
        if (!flag) {
            return false;
        }
        //3.判断相邻的4个地块是否被镇伏 或者 有兽王地块
        boolean isExplore = false;
        //获取相邻上下左右4格的地块
        List<Point> points = PlotUtil.getAdjacentPoints(x, y);
        for (Point point : points) {
            SonHaiPlotData plotData = this.getPlotDataMap().get(point.getKey());
            if (plotData != null && (plotData.getWinFlag() == SonHaiWinFlagEnum.WIN_YES.getType() || plotData.getType() == SonHaiPlotTypeEnum.PLOT_TYPE_1.getType())) {
                isExplore = true;
                break;
            }
        }
        if (!isExplore) {
            return false;
        }
        return true;
    }

    /**
     * 镇伏地块
     * @param x
     * @param y
     * @param addProgress 增加的寻踪进度
     */
    public void winPlot(int x, int y, int addProgress) {
        SonHaiPlotData plotData = this.getPlotDataMap().get(x + "_" + y);
        if (plotData == null || plotData.getWinFlag() == SonHaiWinFlagEnum.WIN_YES.getType()) {
            return;
        }
        plotData.setWinFlag(SonHaiWinFlagEnum.WIN_YES.getType());
        plotData.setWinTime(System.currentTimeMillis());
        //增加寻踪进度
        this.addProgress(addProgress);
    }

    /**
     * 删除区域
     */
    public void delRegion() {
        //区域设置删
        this.setDelFlag(SonHaiDelFlagEnum.DEL_YES.getType());
        //地块设置删除
        for (SonHaiPlotData plotData : this.plotDataMap.values()) {
            plotData.setDelFlag(SonHaiDelFlagEnum.DEL_YES.getType());
        }
    }

    /**
     * 获取兽王地块
     * @return
     */
    public List<SonHaiPlotData> getBossPlotDataList() {
       return this.getPlotTypeDataMap().get(SonHaiPlotTypeEnum.PLOT_TYPE_1.getType());
    }

    /**
     * 判断地块是否被封锁
     * @param x
     * @param y
     * @param sonHaiConfig
     * @return
     */
    public boolean checkPlotLock(int x, int y, SonHaiConfig sonHaiConfig) {
        //获取地块类型为：【瑶碧丘（狰巢）】（封锁周边所有未击败和未探索地块）
        List<SonHaiPlotData> plotDataList = this.getPlotDataListByType(SonHaiPlotTypeEnum.PLOT_TYPE_6.getType());
        if (plotDataList != null) {
            for (SonHaiPlotData plotData : plotDataList) {
                //未镇伏的地块才有减益
                if (plotData.getWinFlag() == SonHaiWinFlagEnum.WIN_NOT.getType()) {
                    //该地块的减益范围是否覆盖了入参：x,y
                    SonHaiEventConfig eventConfig = sonHaiConfig.getEventConfig(plotData.getPlotId());
                    int radius = eventConfig.getParamList().get(0);//读取配置，地块效果范围n
                    boolean flag = PlotUtil.isWithinRange(plotData.getX(), plotData.getY(), radius, x, y);
                    if (flag) {
                        return true;
                    }
                }
            }
        }
        return false;
    }

    /**
     * 获取地块战斗-获取积分减少比例
     * @param x
     * @param y
     * @return
     */
    public int getPlotScoreReduceRate(int x, int y, SonHaiConfig sonHaiConfig) {
        int reduceRate = 0;
        List<SonHaiPlotBuffResp> plotList = this.getPlotScoreReduceRateDetail(x, y, sonHaiConfig);
        for (SonHaiPlotBuffResp info : plotList) {
            reduceRate += info.getValue();
        }
        return reduceRate;
    }

    /**
     * 获取地块战斗-获取积分减少比例-多地块事件
     * @param plots
     * @param sonHaiConfig
     * @return
     */
    public int getPlotScoreReduceRateForMul(List<SonHaiXYData> plots, SonHaiConfig sonHaiConfig) {
        Map<String, SonHaiPlotBuffResp> map = new HashMap<>();
        for (SonHaiXYData xyData : plots) {
            List<SonHaiPlotBuffResp> plotList = this.getPlotScoreReduceRateDetail(xyData.getX(), xyData.getY(), sonHaiConfig);
            for (SonHaiPlotBuffResp info : plotList) {
                String key = info.getX() + "_" + info.getY();
                if (!map.containsKey(key)) {
                    map.put(key, info);
                }
            }
        }
        int reduceRate = 0;
        for (SonHaiPlotBuffResp info : map.values()) {
            reduceRate += info.getValue();
        }
        return reduceRate;
    }

    /**
     * 获取地块战斗-获取积分减少比例-地块LIST
     * @param x
     * @param y
     * @return
     */
    public List<SonHaiPlotBuffResp> getPlotScoreReduceRateDetail(int x, int y, SonHaiConfig sonHaiConfig) {
        List<SonHaiPlotBuffResp> result = new ArrayList<>();
        //获取地块类型为：【钦原巢】（周边X范围内地块的伏兽积分获得 -Y%）
        List<SonHaiPlotData> plotDataList = this.getPlotDataListByType(SonHaiPlotTypeEnum.PLOT_TYPE_5.getType());
        if (plotDataList != null) {
            for (SonHaiPlotData plotData : plotDataList) {
                //未镇伏的地块才有减益
                if (plotData.getWinFlag() == SonHaiWinFlagEnum.WIN_NOT.getType()) {
                    //该地块的减益范围是否覆盖了入参：x,y
                    SonHaiEventConfig eventConfig = sonHaiConfig.getEventConfig(plotData.getPlotId());
                    int radius = eventConfig.getParamList().get(0);//读取配置，地块效果范围半径
                    boolean flag = PlotUtil.isWithinRange(plotData.getX(), plotData.getY(), radius, x, y);
                    if (flag) {
                        int plotReduceRate = eventConfig.getParamList().get(1);//读取配置，地块减益效果plotReduceRate
                        SonHaiPlotBuffResp resp = new SonHaiPlotBuffResp();
                        resp.setPlotEventId(plotData.getPlotId());
                        resp.setX(plotData.getX());
                        resp.setY(plotData.getY());
                        resp.setValue(plotReduceRate);
                        result.add(resp);
                    }
                }
            }
        }
        return result;
    }

    /**
     * 获取地块战斗-异兽战力增加比例
     * @param x
     * @param y
     * @return
     */
    public int getPlotBeatsBattlePowerAddRate(int x, int y, SonHaiConfig sonHaiConfig) {
        int beatsAddRate = 0;
        List<SonHaiPlotBuffResp> plotList = this.getPlotBeatsBattlePowerAddRateDetail(x, y, sonHaiConfig);
        for (SonHaiPlotBuffResp info : plotList) {
            beatsAddRate += info.getValue();
        }
        return beatsAddRate;
    }

    /**
     * 获取地块战斗-异兽战力增加比例-多地块的事件
     * @param plots
     * @param sonHaiConfig
     * @return
     */
    public int getPlotBeatsBattlePowerAddRateForMul(List<SonHaiXYData> plots, SonHaiConfig sonHaiConfig) {
        Map<String, SonHaiPlotBuffResp> map = new HashMap<>();
        for (SonHaiXYData xyData : plots) {
            List<SonHaiPlotBuffResp> plotList = this.getPlotBeatsBattlePowerAddRateDetail(xyData.getX(), xyData.getY(), sonHaiConfig);
            for (SonHaiPlotBuffResp info : plotList) {
                String key = info.getX() + "_" + info.getY();
                if (!map.containsKey(key)) {
                    map.put(key, info);
                }
            }
        }
        int beatsAddRate = 0;
        for (SonHaiPlotBuffResp info : map.values()) {
            beatsAddRate += info.getValue();
        }
        return beatsAddRate;
    }

    /**
     * 获取地块战斗-异兽战力增加比例-地块LIST
     * @param x
     * @param y
     * @return
     */
    public List<SonHaiPlotBuffResp> getPlotBeatsBattlePowerAddRateDetail(int x, int y, SonHaiConfig sonHaiConfig) {
        List<SonHaiPlotBuffResp> result = new ArrayList<>();
        //获取地块类型为：【朱厌巢】（周边地块战力提升X%）
        List<SonHaiPlotData> plotDataList = this.getPlotDataListByType(SonHaiPlotTypeEnum.PLOT_TYPE_7.getType());
        if (plotDataList != null) {
            for (SonHaiPlotData plotData : plotDataList) {
                //未镇伏的地块才有减益
                if (plotData.getWinFlag() == SonHaiWinFlagEnum.WIN_NOT.getType()) {
                    //该地块的减益范围是否覆盖了入参：x,y
                    SonHaiEventConfig eventConfig = sonHaiConfig.getEventConfig(plotData.getPlotId());
                    int radius = eventConfig.getParamList().get(0);//读取配置，地块效果范围半径
                    boolean flag = PlotUtil.isWithinRange(plotData.getX(), plotData.getY(), radius, x, y);
                    if (flag) {
                        int plotBeastAddRate = eventConfig.getParamList().get(1);//读取配置，地块减益效果plotBeastAddRate
                        SonHaiPlotBuffResp resp = new SonHaiPlotBuffResp();
                        resp.setPlotEventId(plotData.getPlotId());
                        resp.setX(plotData.getX());
                        resp.setY(plotData.getY());
                        resp.setValue(plotBeastAddRate);
                        result.add(resp);
                    }
                }
            }
        }
        return result;
    }

    /**
     * 获取地块战斗-镇伏后寻踪进度减少值
     * @param x
     * @param y
     * @return
     */
    public int getPlotProgressReduceValue(int x, int y, SonHaiConfig sonHaiConfig) {
        int reduceValue = 0;
        List<SonHaiPlotBuffResp> plotList = this.getPlotProgressReduceValueDetail(x, y, sonHaiConfig);
        for (SonHaiPlotBuffResp info : plotList) {
            reduceValue += info.getValue();
        }
        return reduceValue;
    }

    /**
     * 获取地块战斗-镇伏后寻踪进度减少值-地块LIST
     * @param x
     * @param y
     * @return
     */
    public List<SonHaiPlotBuffResp> getPlotProgressReduceValueDetail(int x, int y, SonHaiConfig sonHaiConfig) {
        List<SonHaiPlotBuffResp> result = new ArrayList<>();
        //获取地块类型为：【沙漠】（镇伏周边地块获得的寻踪进度-X）
        List<SonHaiPlotData> plotDataList = this.getPlotDataListByType(SonHaiPlotTypeEnum.PLOT_TYPE_8.getType());
        if (plotDataList != null) {
            for (SonHaiPlotData plotData : plotDataList) {
                //未镇伏的地块才有减益
                if (plotData.getWinFlag() == SonHaiWinFlagEnum.WIN_NOT.getType()) {
                    //该地块的减益范围是否覆盖了入参：x,y
                    SonHaiEventConfig eventConfig = sonHaiConfig.getEventConfig(plotData.getPlotId());
                    int radius = eventConfig.getParamList().get(0);//读取配置，地块效果范围n
                    boolean flag = PlotUtil.isWithinRange(plotData.getX(), plotData.getY(), radius, x, y);
                    if (flag) {
                        int plotReduceValue = eventConfig.getParamList().get(1);//读取配置，地块减益效果plotReduceValue
                        SonHaiPlotBuffResp resp = new SonHaiPlotBuffResp();
                        resp.setPlotEventId(plotData.getPlotId());
                        resp.setX(plotData.getX());
                        resp.setY(plotData.getY());
                        resp.setValue(plotReduceValue);
                        result.add(resp);
                    }
                }
            }
        }
        return result;
    }

    /**
     * 获取战力加成比例-地块收益
     * @return
     */
    public int getBattlePowerAddRateFromPlot(SonHaiConfig sonHaiConfig) {
        int addRate = 0;
        //获取地块类型为：【灵草田】（镇伏后玩家与异兽战斗时获得战力增益）
        List<SonHaiPlotData> plotDataList = this.getPlotDataListByType(SonHaiPlotTypeEnum.PLOT_TYPE_3.getType());
        if (plotDataList != null) {
            for (SonHaiPlotData plotData : plotDataList) {
                //已镇伏才有加成
                if (plotData.getWinFlag() == SonHaiWinFlagEnum.WIN_YES.getType()) {
                    //读配置，获取地块事件配置，加成rate值
                    SonHaiEventConfig eventConfig = sonHaiConfig.getEventConfig(plotData.getPlotId());
                    int plotAddRate = eventConfig.getParamList().get(1);
                    addRate += plotAddRate;
                }
            }
        }
        return addRate;
    }

    /**
     * 获取积分加成比例-地块收益
     * @return
     */
    public int getScoreAddRateFromPlot(SonHaiConfig sonHaiConfig) {
        int addRate = 0;
        //获取地块类型为：【灵矿】（镇伏后玩家获得的伏兽积分+X%）
        List<SonHaiPlotData> plotDataList = this.getPlotDataListByType(SonHaiPlotTypeEnum.PLOT_TYPE_4.getType());
        if (plotDataList != null) {
            for (SonHaiPlotData plotData : plotDataList) {
                //已镇伏才有加成
                if (plotData.getWinFlag() == SonHaiWinFlagEnum.WIN_YES.getType()) {
                    //读配置，获取地块配置，加成rate值
                    SonHaiEventConfig eventConfig = sonHaiConfig.getEventConfig(plotData.getPlotId());
                    int plotAddRate = eventConfig.getParamList().get(1);
                    addRate += plotAddRate;
                }
            }
        }
        return addRate;
    }
}
